﻿
using System;
using System.Collections.Generic;

namespace TestYeild
{
    class Program
    {
        static void Main(string[] args)
        {

            foreach (int i in TestYeild())
            {
                Console.WriteLine(i);
            }
            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }

        public static IEnumerable<int> TestYeild()
        {
            List<int> ls = new List<int>() { 1, 2, 3, 4 };

            foreach (int x in ls)
            {
                if (x % 2 == 0)
                {
                    Console.WriteLine("等待");
                    yield return x;
                }
            }
            yield return 0;
        }
    }
}
